struct Rectangle {
    width: u32,
    height: u32,
}

// 实现结构体
impl Rectangle {
     // 方法
    fn area(&self) -> u32 {
        self.width * self.height
    }
     // 关联函数 静态的
    fn square(size: u32) -> Rectangle {
        Rectangle {
            width: size,
            height: size,
        }
    }
}

fn main() {
    let rect = Rectangle { width: 30, height: 50 };
    println!("宽: {}, 高：{}", rect.width, rect.height);
    println!("长方形面积: {}", rect.area());
    let square = Rectangle::square(100);
    println!("正方形面积: {}", square.area());
}
